//------------------------------------------------------------------------------
// Sim Magellan Service
//
// Professional Microsoft Robotics Developer Studio
//
// Updated for RDS 2008 (V2.0)
//
//------------------------------------------------------------------------------

using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using System;
using System.Collections.Generic;
using W3C.Soap;
using magellan = ProMRDS.Simulation.Magellan;


namespace ProMRDS.Simulation.Magellan
{
    
    /// <summary>
    /// SimMagellan Contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// The Dss Service contract
        /// </summary>
        public const String Identifier = "http://www.promrds.com/contracts/2007/08/simmagellan.html";
    }

    [DataContract]
    public enum ModeType
    {
        NotSpecified = 0,
        Reset,
        Ready,
        Wander,
        AvoidCollision,
        Approach,
        FinalApproach,
        BackAway,
        Finished
    }

    /// <summary>
    /// The SimMagellan State
    /// </summary>
    [DataContract()]
    public class SimMagellanState
    {
        [DataMember]
        public ModeType CurrentMode;
    }
    /// <summary>
    /// SimMagellan Main Operations Port
    /// </summary>
    [ServicePort()]
    public class SimMagellanOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get>
    {
    }
    /// <summary>
    /// SimMagellan Get Operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<SimMagellanState, Fault>>
    {
        /// <summary>
        /// SimMagellan Get Operation
        /// </summary>
        public Get()
        {
        }
        /// <summary>
        /// SimMagellan Get Operation
        /// </summary>
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body) : 
                base(body)
        {
        }
        /// <summary>
        /// SimMagellan Get Operation
        /// </summary>
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body, Microsoft.Ccr.Core.PortSet<SimMagellanState,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }
    #region WinForms communication

    public class FromWinformEvents : Port<FromWinformMsg>
    {
    }

    public class FromWinformMsg
    {
        public enum MsgEnum
        {
            Loaded,
            Reset,
            Test,
            Start,
        }

        private string[] _parameters;
        public string[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        private MsgEnum _command;
        public MsgEnum Command
        {
            get { return _command; }
            set { _command = value; }
        }

        private object _object;
        public object Object
        {
            get { return _object; }
            set { _object = value; }
        }

        public FromWinformMsg(MsgEnum command, string[] parameters)
        {
            _command = command;
            _parameters = parameters;
        }
        public FromWinformMsg(MsgEnum command, string[] parameters, object objectParam)
        {
            _command = command;
            _parameters = parameters;
            _object = objectParam;
        }
    }
    #endregion

    #region Custom Image Processing
    /// <summary>
    /// ImageProcessResult
    /// </summary>
    [DataContract]
    public class ImageProcessResult
    {
        /// <summary>
        /// X Mean
        /// </summary>
        [DataMember]
        public int XMean;

        /// <summary>
        /// Percentage of image XMean is right from Center
        /// </summary>
        [DataMember]
        public float RightFromCenter;

        /// <summary>
        /// Y Mean
        /// </summary>
        [DataMember]
        public int YMean;

        /// <summary>
        /// Percentage of image YMean is down from Center
        /// </summary>
        [DataMember]
        public float DownFromCenter;

        /// <summary>
        /// Area
        /// </summary>
        [DataMember]
        public int Area;

        /// <summary>
        /// TimeStamp
        /// </summary>
        [DataMember]
        public DateTime TimeStamp;

        /// <summary>
        /// Threshold for identification of a cone
        /// </summary>
        [DataMember]
        public int AreaThreshold = 50*50;
#if false
        public double XStdDev;
        public double YStdDev;
        public double XSkew;
        public double YSkew;
#endif
    }

    #endregion
}
